<template>
  <div class="login">
      <div class="sjhm">
          <input type="text" placeholder="手机号码"
          v-model="username">
      </div>
      <div class="mm">
          <input type="password" placeholder="密码"
          v-model="password">
      </div>
      <div class="dl" @click="login">登录</div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
         username:''   ,
         password:''
        }
    },
    methods:{
        login(){
            axios.post('/login',{username:this.username,password:this.password}).then(res=>{
              if(res.data.code===200){
                  localStorage.setItem('token',res.data.token)
                  this.$router.push('/home')
              }else{
                 alert(res.data.msg+'，请重新输入');
                 location=location
              };
            })
        }
    }
}
</script>

<style>
.login{
    line-height: 50px;
    padding: 0 20px;
}
.sjhm{

}
input{
    outline: none;
    border: none;
    border-bottom: 1px solid #ccc;
    width: 100%;
}
.dl{
    background: rgb(132, 131, 131);
    color:aliceblue;
    border-radius: 25px;
}
</style>